def validate_input(data: dict, required_fields: dict) -> bool:
    """
    验证输入数据是否包含必要字段

    参数:
        data: 输入数据字典
        required_fields: 各部分的必要字段 {
            'section1': ['field1', 'field2'],
            'section2': []
        }

    返回:
        bool: 是否验证通过
    """

    # 如果是列表类型
    if isinstance(required_fields, list):
        for field in required_fields:
            if field not in data or not data[field]:
                return False
        return True

    # 原有字典处理逻辑
    elif isinstance(required_fields, dict):

        for section, fields in required_fields.items():
            if section not in data:
                if fields:  # 如果该部分有必填字段但数据中缺少该部分
                    return False
                continue

        for field in fields:
            if field not in data[section] or data[section][field] is None:
                return False
    return True


def validate_types(data: dict, type_rules: dict) -> bool:
    """
    验证字段数据类型

    参数:
        data: 输入数据
        type_rules: 类型规则 {'field': type}

    返回:
        bool: 是否类型匹配
    """
    for field, expected_type in type_rules.items():
        if not isinstance(data.get(field), expected_type):
            return False
    return True